#include <assert.h>
#include "scene.h"
#include "ctrlboard.h"
#include "mg_Lcd_Driver.h"
#include "mg_Device.h"
/* widgets:
Layer_AClock
Button1
AClock_Background
Icon_Center
AnalogClock
Icon_MinuteHand
Icon_HourHand
DigitalClock1
Text_Day
*/

static ITUAnalogClock* AnalogClock;
static ITUBackground* AClock_Background;

void SetAClockTime(int hour, int minute, int second);
bool AClockOnTimer(ITUWidget* widget, char* param)
{
	if (Action_Cmd.User_Action != Null_Action)
	{
		Action_Cmd.User_Action = Null_Action;
		Action_Cmd.Action_Times = 0;
		GotoMainMenu();
	}
    return true;
}
bool AClockOnEnter(ITUWidget* widget, char* param)
{
	if (!AnalogClock)
	{
		AnalogClock = ituSceneFindWidget(&theScene, "AnalogClock");
		assert(AnalogClock);
		AClock_Background = ituSceneFindWidget(&theScene, "AClock_Background");
		assert(AClock_Background);
	}
	MessageFlag[MSG_GET_TIME] = ON;//对时
	//设置时钟更新
	ituAnalogClockUpdate((ITUWidget*)AnalogClock, ITU_EVENT_TIMER, 0, 0, 0);

    return true;
}
//右滑返回主菜单
bool SlideRightToBackMainmenu(ITUWidget* widget, char* param)
{
	ITULayer* Layer_MainMenu = ituSceneFindWidget(&theScene, "Layer_MainMenu");
	ITULayer* Layer_MainMenu2 = ituSceneFindWidget(&theScene, "Layer_MainMenu2");
	//判断系统菜单类型并跳转到对应菜单
	if (DisplayValue.MainMenuDisplay == MAINMENU_COVERFLOW_MODE0)
	{
		assert(Layer_MainMenu);
		ituLayerGoto(Layer_MainMenu);
	}
	else if (DisplayValue.MainMenuDisplay == MAINMENU_WHEELBACKGROUND)
	{
		assert(Layer_MainMenu2);
		ituLayerGoto(Layer_MainMenu2);
	}
}
//函数接口返回主菜单
void GotoMainMenu(void)
{
	ITULayer* Layer_MainMenu = ituSceneFindWidget(&theScene, "Layer_MainMenu");
	ITULayer* Layer_MainMenu2 = ituSceneFindWidget(&theScene, "Layer_MainMenu2");
	//判断系统菜单类型并跳转到对应菜单
	if (DisplayValue.MainMenuDisplay == MAINMENU_COVERFLOW_MODE0)
	{
		assert(Layer_MainMenu);
		ituLayerGoto(Layer_MainMenu);
	}
	else if (DisplayValue.MainMenuDisplay == MAINMENU_WHEELBACKGROUND)
	{
		assert(Layer_MainMenu2);
		ituLayerGoto(Layer_MainMenu2);
	}
}
